<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreatePlantVarietiesTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('plant_varieties', function (Blueprint $table) {
            $table->id();
            $table->string('uuid', 32)->unique()->comment('编号');
            $table->string('name')->comment('品种名称');
            $table->string('from')->nullable()->comment('品种来源');
            $table->string('applicant')->nullable()->comment('申请者');
            $table->string('breeder')->nullable()->comment('育种者');
            $table->string('breeding_person')->nullable()->comment('育种人');
            $table->string('publication_no')->nullable()->comment('公告号');
            $table->string('cert_no', 30)->nullable()->comment('证书号');
            $table->string('approved_no', 30)->nullable()->comment('审定编号');
            $table->string('cert')->nullable()->comment('证书附件');
            $table->string('level')->nullable()->comment('登记级别');
            
            $table->string('mobile')->nullable();

            $table->integer('department_id')->default(0);
            $table->integer('user_id')->default(0);

            $table->tinyInteger('status')->default(0);
            $table->tinyInteger('review_status')->default(0);
            $table->tinyInteger('dept_review_status')->default(0);
            $table->text('review_remark')->nullable();

            $table->year('year')->nullable()->comment('年份');
            $table->integer('serial_number')->default(0)->comment('序号');
            $table->timestamps();

            $table->index('year');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('plant_varieties');
    }
}
